<?php
	header("Content-type: text/html;charset=utf8");
	require_once("../db/dbclass.php");
	require_once("../utils/common.php");
	require_once("../utils/config.php");
	$myDb=&DbController::getInstance();
	$user_id=$_POST['user_id'];
	$param="SELECT * FROM(SELECT user1_id FROM yj_friend WHERE user2_id = $user_id) AS t1 INNER JOIN yj_user_info AS t2 ON t1.user1_id=t2.user_id";
	$result=$myDb->exec_query($param);
	$friends="";
	if($result==TRUE){
		$row_num = mysqli_num_rows($result);
		$friends=array($row_num);
		$i=0;
		while($row=mysqli_fetch_array($result,MYSQL_ASSOC)){
			$array_i=array(
				"id"=>$row['user_id'],
				"nickname"=>$row['user_name'],
				"img_url"=>URL.substr($row['user_photo'],2)
			);
			$friends[$i++]=$array_i;
		}
		$result="success";
	}
	else{
		$result="failure";
	}
	$arr=array(
		"result"=>$result,
		"friends"=>$friends
	);
	echo json_encode($arr);
?>